package com.samoiloff.ui.list.smart.model {
	import com.samoiloff.ui.list.smart.interfaces.CellRenderer;
	import com.samoiloff.ui.list.smart.interfaces.ILayout;

	import flash.geom.Rectangle;

	/**
	 * @author Samoiloff
	 */
	public class DefaultLayout implements ILayout {
		
		protected var _contentHeight:Number;
		
		public function DefaultLayout() {
			_contentHeight = 0;
		}

		public function apply(arr: Array, bounds:Rectangle = null): void {
			_contentHeight = 0;
			if (arr) {
				for (var i:int = 0; i<arr.length; i++) {
					var cellRenderer:CellRenderer = arr[i] as CellRenderer;
					
					cellRenderer.setBounds(new Rectangle(0, _contentHeight, bounds.width, 0));
					//cellRenderer.visible = false;
					
					_contentHeight = cellRenderer.boundsY + cellRenderer.boundsHeight;
				}
			}
		}
		
		public function get contentHeight(): Number {
			return _contentHeight;
		}
		
	}
}
